package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo10 {
    public static void main(String[] args) {
        try (Connection conn = DBUtil.getConnection()){
            Statement statement = conn.createStatement();
            String sql = "UPDATE user SET password=?,nickname=?,age=? "+
                         "WHERE id=?";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1,"222222");
            ps.setString(2,"帅哥");
            ps.setInt(3,23);
            ps.setInt(4,5);
            int num = ps.executeUpdate();
            System.out.println(num>0?"修改成功":"修改失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
